package org.vy.dal.dao.admin;

import org.vy.dal.QueryManager;
import org.vy.dal.dao.lookup.VyLookupDeliveryModeDO;

public class VyAdmGroupsDAO {
	private static final String FIND_BY_PK = "SELECT * FROM <TABLE> WHERE DELIVERY_MODE_CODE = m_deliveryModeCode";
	private static final String UPDATE = "UPDATE <TABLE> SET DELIVERY_MODE_NAME_NAME = m_deliveryModeName, IS_ACTIVE = m_isActive, LAST_UPDATED_BY = m_lastUpdatedBy, LAST_UPDATED_ON = m_lastUpdatedOn WHERE DELIVERY_MODE_CODE = m_deliveryModeCode";
	private static final String INSERT = "INSERT INTO <TABLE> (DELIVERY_MODE_CODE,DELIVERY_MODE_NAME,IS_ACTIVE,LAST_UPDATED_BY,LAST_UPDATED_ON) VALUES(m_deliveryModeCode,m_deliveryModeName,m_isActive,m_lastUpdatedBy,m_lastUpdatedOn)";
	private static final String DELETE = "DELETE FROM <TABLE> WHERE DELIVERY_MODE_CODE = m_deliveryModeCode";

	public static VyLookupDeliveryModeDO findByPK(String key) throws Exception {
		VyLookupDeliveryModeDO dto = new VyLookupDeliveryModeDO();
		dto.setDeliveryModeCode(key);
		dto = (VyLookupDeliveryModeDO) QueryManager.executeQuery(dto, FIND_BY_PK);
		return dto;
	}
	public static VyLookupDeliveryModeDO insert(VyLookupDeliveryModeDO dto) throws Exception {

		dto = (VyLookupDeliveryModeDO) QueryManager.executeInsert(dto, INSERT);
		return dto;
	}

	public static VyLookupDeliveryModeDO update(VyLookupDeliveryModeDO dto) throws Exception {
		int i = QueryManager.executeUpdate(dto, UPDATE);
		if (i > 0)
			return dto;
		else
			return null;
	}

	public static VyLookupDeliveryModeDO delete(String key) throws Exception {
		VyLookupDeliveryModeDO dto = new VyLookupDeliveryModeDO();
		dto.setDeliveryModeCode(key);
		boolean i = QueryManager.executeDelete(dto, DELETE);
		if (i == true)
			return dto;
		else
			return null;
	}

}
